_require "basis.smi"
_require "base.sig"

structure LrTable =
struct
  datatype ('a, 'b) pairlist = EMPTY | PAIR of 'a * 'b * ('a, 'b) pairlist
  datatype state = STATE of int
  datatype term = T of int
  datatype nonterm = NT of int
  datatype action = SHIFT of state | REDUCE of int | ACCEPT | ERROR
  type table (= boxed)
  val numStates : table -> int
  val numRules : table -> int
  val describeActions : table -> state -> (term, action) pairlist * action
  val describeGoto : table -> state -> (nonterm, state) pairlist
  val action : table -> state * term -> action
  val goto : table -> state * nonterm -> state
  val initialState : table -> state
  exception Goto of state * nonterm
  val mkLrTable : {actions : ((term, action) pairlist * action) array,
                   gotos : (nonterm, state) pairlist array,
                   numStates : int, numRules : int,
                   initialState : state} -> table
end
